<template>
  <el-form :inline="true" :model="form" size="small">
    <el-form-item v-for="item in items" :key="item.prop" :label="item.label">
      <ModuleInput v-model="form.data[item.prop]" :type="item.type" :options="item.options" />
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="handleSarch">
        查询
      </el-button>
      <el-button type="primary" @click="$emit('addRow')">
        添 加
      </el-button>
    </el-form-item>
  </el-form>
</template>

<script lang="ts">
import ModuleInput from '@/components/FreeInput.vue'
import { defineComponent, reactive } from 'vue'

export default defineComponent({
  name: 'SearchModule',
  components: {
    ModuleInput,
  },
  props: {
    // 表单列表渲染配置
    items: {
      type: Array,
      required: true,
    },
  },
  emits: ['search', 'addRow'],
  setup() {
    const form = reactive({
      data: {},
    })

    return {
      form,
    }
  },
  methods: {
    handleSarch() {
      this.$emit('search', this.form.data)
    },
  },
})
</script>

<style lang="scss" scoped>
//
</style>
